#include "ui/menudef.h"
#include "ui_mp/popupstyle.inc"

#undef MENU_CENTERPOPUP_SETUP
#define MENU_CENTERPOPUP_SETUP( nameArg, textTArg, textFArg, sizexArg, sizeyArg, borderSizeArg ) \
	name   nameArg \
	fullscreen  0 \
	rect   (0-((sizexArg)/2)) (0-((sizeyArg)/2)) (sizexArg) (sizeyArg) HORIZONTAL_ALIGN_CENTER VERTICAL_ALIGN_CENTER \
	border   1 \
	backcolor  0 0 0 0 \
	bordersize  borderSizeArg \
	bordercolor  1 1 1 0.5 \
	focusColor  1 1 1 1 \
	style   WINDOW_STYLE_FILLED \
	popup \
	onOpen \
	{ \
		focusfirst; \
		setLocalVarBool    ui_centerPopup 1; \
	} \
	onClose \
	{ \
		play "mouse_click"; \
		setLocalVarBool    ui_centerPopup 0; \
	} \
	onESC \
	{ \
		setLocalVarBool    ui_centerPopup 0; \
		close self; \
	} \
	itemDef \
	{ \
		style   WINDOW_STYLE_SHADER \
		rect   0 0 ((sizexArg) - ((borderSizeArg) * 2)) ((sizeyArg) - ((borderSizeArg) * 2)) HORIZONTAL_ALIGN_CENTER VERTICAL_ALIGN_CENTER \
		background  "white" \
		bordercolor 0.316 0.352 0.277 1 \
		forecolor  0.316 0.352 0.277 1 \
		backcolor  0.316 0.352 0.277 1 \
		visible   1 \
		decoration \
	} \
	itemDef \
	{ \
		style   WINDOW_STYLE_SHADER \
		rect   -600 -800 2000 2000 0 0 \
		forecolor  0 0 0 0.475 \
		exp    material( "white" ); \
		visible   1 \
		decoration \
	} \
	itemDef \
	{ \
		style   WINDOW_STYLE_FILLED \
		rect   0 0 (sizexArg - ((borderSizeArg) * 2)) 22 HORIZONTAL_ALIGN_CENTER VERTICAL_ALIGN_CENTER \         
        backcolor 0.156 0.176 0.160 1 \
		visible   1 \
		decoration \
	} \
	itemDef \
	{ \
		style   WINDOW_STYLE_SHADER \
		rect   0 (0 + 22) (sizexArg - ((borderSizeArg) * 2)) 3 HORIZONTAL_ALIGN_CENTER VERTICAL_ALIGN_CENTER \
		forecolor  1 1 1 1 \
		exp    material("gradient_top"); \
		border   0 \
		bordersize  0 \
		bordercolor  0 0 0 0 \
		visible   1 \
		decoration \
	} \
	itemDef \
	{ \  
		style   ITEM_TYPE_TEXT \
		rect   0 0 (sizexArg - ((borderSizeArg) * 2)) 22 HORIZONTAL_ALIGN_CENTER VERTICAL_ALIGN_CENTER \  
		forecolor  1 1 1 0.8 \
		exp    text( textTArg ) \        
		textfont  9 \
		textscale  0.375 \   
		textstyle  0 \
		textalign  ITEM_ALIGN_MIDDLE_LEFT \
		textalignX  8 \   
		visible   1 \
		decoration \
	} \
	itemDef \
	{ \  
		style   ITEM_TYPE_TEXT \
		rect   0 15 (sizexArg - ((borderSizeArg) * 2)) 40 HORIZONTAL_ALIGN_CENTER VERTICAL_ALIGN_CENTER \  
		autowrapped \   
		forecolor  1 1 1 0.95 \
		exp    text( textFArg ) \        
		textfont  3 \
		textscale  0.375 \   
		textstyle  0 \
		textalign  ITEM_ALIGN_MIDDLE_LEFT \
		textalignX  8 \   
		visible   1 \
		decoration \
	}  
   
#undef MENU_CENTERPOPUP_BUTTON  
#define MENU_CENTERPOPUP_BUTTON( indexArg, rectXArg, rectYArg, textArg, sizeXArg, sizeYArg, actionArg )    \
	itemDef \
	{ \
		style   WINDOW_STYLE_FILLED \
		rect   (rectXArg) (rectYArg) (sizeXArg) (sizeYArg) HORIZONTAL_ALIGN_CENTER VERTICAL_ALIGN_CENTER \
		backcolor  0.215 0.234 0.223 1 \
		visible   1 \
		decoration \
	} \
	itemDef \
	{ \
		style   WINDOW_STYLE_SHADER \
		rect   (rectXArg) (rectYArg) (sizeXArg) (sizeYArg) HORIZONTAL_ALIGN_DEFAULT VERTICAL_ALIGN_DEFAULT \
		background  "gradient_fadein" \
		forecolor  0.488 0.520 0.465 1 \
		visible   when( localVarInt( ui_highlight_popup ) == indexArg && localVarString( ui_choicegroup ) == "popmenu" ); \
		decoration \
	} \
	itemDef \
	{ \
		style   WINDOW_STYLE_FILLED \
		rect   (rectXArg) (rectYArg + ((sizeYArg) - 2)) (sizeXArg) 2 HORIZONTAL_ALIGN_CENTER VERTICAL_ALIGN_CENTER \
		backcolor  0 0 0 1 \
		visible   when( localVarInt( ui_highlight_popup ) == indexArg && localVarString( ui_choicegroup ) == "popmenu" ); \
		decoration \
	} \  
	itemDef \
	{ \
		type   ITEM_TYPE_BUTTON \
		rect            (rectXArg) (rectYArg) (sizeXArg) (sizeYArg) HORIZONTAL_ALIGN_DEFAULT VERTICAL_ALIGN_DEFAULT \
		exp    text( textArg ); \
		textfont  3 \
		textscale  0.375 \
		textstyle  ITEM_TEXTSTYLE_SHADOWED \
		textAlign  ITEM_ALIGN_MIDDLE_LEFT \
		textAlignX  8 \
		forecolor  1 1 1 0.95 \
		visible   1 \
		onFocus \
		{ \
			play "mouse_submenu_over"; \
			setLocalVarInt ui_highlight_popup indexArg; \
			setLocalVarString ui_choicegroup "popmenu"; \
		} \
		leaveFocus \
		{ \
			setLocalVarInt ui_highlight_popup 0; \
		} \
		action \
		{ \
			play "mouse_click"; \
			actionArg; \
		} \
	}